<template>
  <div>
    <el-dialog
      v-model="dialogVisible"
      width="80%"
      align-center
      :show-close="false"
      destroy-on-close
      draggable
      @open="handleOpen"
    >
      <template #header="{ close }">
        <div class="dialog-header flex justify-between items-center">
          <div>项目审核</div>
          <el-icon class="el-icon--left cursor-pointer" @click="close"
            ><CircleCloseFilled color="#fff"
          /></el-icon>
        </div>
      </template>
      <!-- 项目信息 -->
      <ProjectInfo :detailData="detailData" />
      <!-- 成员信息 -->
      <ProjectMember />
      <!-- 预算明细 -->
      <ProjectBudget />
      <template #footer>
        <div class="dialog-footer">
          <Checkcomponents :procInsId="procInsId" class="mt-[10px]" @success="checkSuccess" />
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import Checkcomponents from "@/views/flowable/processInstance/detail/components.vue";
import ProjectInfo from "./ProjectInfo.vue";
import ProjectMember from "./ProjectMember.vue";
import ProjectBudget from "./ProjectBudget.vue";
import useCommonFetch from "@/hooks/useCommonFetch";
import { sbBaseDetail } from "@/api/project/xj/sbxm";
/**获取公共下拉数据开始*/
const sexList = useCommonFetch("人员-性别(男女)");
const executivePostList = useCommonFetch("行政职务");
const applierEduDegreeList = useCommonFetch("学位");
const applierTitleList = useCommonFetch("职称");
const researchBaseTypeList = useCommonFetch("所在研究基地类型");
const projectTypeList = useCommonFetch("项目分类（校级）");
const nationalIndustryList = useCommonFetch("国民经济行业");
const technologyActivityList = useCommonFetch("科技活动类型");
const subjectList = useCommonFetch("一级学科");
const unitList = useCommonFetch("成果归属单位");
const allUnitList = useCommonFetch("所有单位");
const memberList = useCommonFetch("成员类型");
provide("sexList", sexList); //性别
provide("executivePostList", executivePostList); //行政职务
provide("applierEduDegreeList", applierEduDegreeList); //学位
provide("applierTitleList", applierTitleList); //职称
provide("researchBaseTypeList", researchBaseTypeList); //所在研究基地类型
provide("projectTypeList", projectTypeList); //项目分类
provide("nationalIndustryList", nationalIndustryList); //国民行业
provide("technologyActivityList", technologyActivityList); //科技活动类型
provide("subjectList", subjectList); //一级学科
provide("unitList", unitList); //所属单位
provide("allUnitList", allUnitList);
provide("memberList", memberList); //成员类型
const dialogVisible = ref(false);
const operateId = ref(null);
const procInsId = ref(null); //流程实例id
const detailData = ref({});
provide("id", operateId);
//获取申报基础信息
const getBaseDetail = async () => {
  const params = {
    id: operateId.value,
  };
  try {
    const res = await sbBaseDetail(params);
    detailData.value = res.data;
  } catch (error) {
    console.log(error);
  }
};
const check = (id, processId) => {
  operateId.value = id;
  procInsId.value = processId;
  dialogVisible.value = true;
};
defineExpose({ check });
const handleOpen = () => {
  getBaseDetail();
};
const emit = defineEmits(["check-success"]);
const checkSuccess = () => {
  dialogVisible.value = false;
  emit("check-success");
};
</script>

<style scoped lang="scss">
@import url("@/views/project/index.scss");
:deep(.el-dialog__body) {
  height: calc(100% - 180px);
}
</style>
